﻿@{
    @using YiSha.Entity.Business;
    @using YiSha.Util.Extension;
    @using YiSha.Enum;
    @using YiSha.Enum.OrganizationManage; Layout = "~/Views/Shared/_FormWhite.cshtml"; }
<style>

    table {
        border-collapse: collapse;
        border: 1px solid #000000;
    }

    td {
        border-collapse: collapse;
        border: 1px solid #000000;
        height: 30px
    }

    input {
        border: none;
        border-bottom: #8D8D8D 1px solid;
        box-shadow: 0px 0px 0px 0px;
    }

    .noneinput {
        border: none;
        border-bottom: #8D8D8D 0px solid;
        box-shadow: 0px 0px 0px 0px;
    }

    .divtitle {
        float: left;
        vertical-align: middle;
        text-align: center;
        line-height: 30px;
        padding-left: 10px
    }
</style>
<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <input type="hidden" id="personId" />
        <input type="hidden" id="isEnd" col="IsEnd" />
        <table width="100%">
            <tr>

                <td>姓名：<input id="realName" col="RealName" class="noneinput" type="text" /></td>
                <td>性别：<input id="genderText" col="GenderText" class="noneinput" type="text" /></td>
                <td>年龄：<input id="age" col="Age" class="noneinput" type="text" /></td>
            </tr>
            <tr>
                <td colspan="3">身份： <input id="occupationTest" col="OccupationTest" class="noneinput" type="text" /></td>

            </tr>
            <tr>
                <td>手机号：<input id="mobile" type="text" col="Mobile" class="noneinput" /></td>
                <td colspan="2">工作单位：<input id="workUnit" col="WorkUnit" class="noneinput" type="text" /></td>
            </tr>
            <tr>
                <td colspan="3" style="border-bottom:0px">家庭住址：<input id="address" col="Address" class="noneinput" type="text" /></td>
            </tr>
            <tr>
                <td colspan="3" style="border:0px">
                    <table width="100%">

                        @*视力情况*@
                        <tr>
                            <td rowspan="10" align="center">
                                视力情况
                            </td>
                            <td rowspan="2" align="center">
                                是否近视 <input type="checkbox" id="isMyopia" col="IsMyopia" />
                            </td>
                            <td colspan="2" align="left">
                                &nbsp; &nbsp; &nbsp;左眼 ：
                                <input id="myopiaLefEyeText" col="MyopiaLefEyeText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" align="left">
                                &nbsp; &nbsp; &nbsp;右眼 ：
                                <input id="myopiaRightEyeText" col="MyopiaRightEyeText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td rowspan="2" align="center">
                                是否散光  <input type="checkbox" id="isAstigmatism" col="IsAstigmatism" />
                            </td>
                            <td colspan="2" align="left">
                                &nbsp; &nbsp; &nbsp;左眼 ：
                                <input id="astigmatismLefEyeText" col="AstigmatismLefEyeText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" align="left">
                                &nbsp; &nbsp; &nbsp;右眼 ：
                                <input id="astigmatismRightEyeText" col="AstigmatismRightEyeText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td rowspan="2" align="center">
                                是否弱视  <input type="checkbox" id="isAmblyopia" col="IsAmblyopia" />
                            </td>
                            <td colspan="2" align="left">
                                &nbsp; &nbsp; &nbsp;左眼 ：
                                <input id="amblyopiaLefEyeText" col="AmblyopiaLefEyeText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" align="left">
                                &nbsp; &nbsp; &nbsp;右眼 ：
                                <input id="amblyopiaRightEyeText" col="AmblyopiaRightEyeText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                &nbsp;&nbsp;&nbsp;干眼症 <input type="checkbox" id="isXerophthalmia" col="IsXerophthalmia" />
                            </td>
                            <td colspan="3" align="left">
                                &nbsp; 治疗史 ：
                                <input id="xerophthalmiaText" col="XerophthalmiaText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                &nbsp;&nbsp;&nbsp;飞蚊症 <input type="checkbox" id="isFeiWenZheng" col="IsFeiWenZheng" />
                            </td>
                            <td colspan="3" align="left">
                                &nbsp; 治疗史 ：
                                <input id="feiWenZhengText" col="FeiWenZhengText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                是否花眼 <input type="checkbox" id="isPresbyopia" col="IsPresbyopia" />
                            </td>
                            <td colspan="3" align="left">
                                &nbsp; 治疗史 ：
                                <input id="presbyopiaText" col="PresbyopiaText" type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                眼部衰老 <input type="checkbox" id="isEyeAging" col="IsEyeAging" />
                            </td>
                            <td colspan="3" align="left">
                                &nbsp; 治疗史 ：
                                <input id="eyeAgingText" col="EyeAgingText" type="text" />
                            </td>
                        </tr>

                        @*睡眠情况*@
                        <tr>
                            <td rowspan="4" align="center">
                                睡眠情况
                            </td>
                            <td colspan="3">
                                <div class="divtitle"> 睡眠时间：</div>  <div id="sleepTimeValue" style="float: left;" col="SleepTimeValue"></div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 是否熬夜：</div>  <div id="isStayUpLate" style="float: left;" col="IsStayUpLate"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 睡眠习惯：</div>  <div id="sleepHabitsValue" style="float: left;" col="SleepHabitsValue"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 睡眠情况：</div>  <div id="sleepQualityValue" style="float: left;" col="SleepQualityValue"></div>
                            </td>
                        </tr>


                        @*用眼情况*@
                        <tr>
                            <td rowspan="4" align="center">
                                用眼情况
                            </td>
                            <td colspan="3">
                                <div class="divtitle"> 持续用眼时间：</div>  <div id="eyeUseTimeValue" style="float: left;" col="EyeUseTimeValue"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 用眼方式：</div>  <div id="eyeUseTypes" style="float: left;" col="EyeUseTypes"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 用眼时间段：</div>  <div id="eyeUsePeriodS" style="float: left;" col="EyeUsePeriodS"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 用眼最长时间：</div>  <div id="eyeUseTimeLongestValue" style="float: left;" col="EyeUseTimeLongestValue"></div>
                            </td>
                        </tr>

                        @*基本健康情况*@
                        <tr>
                            <td rowspan="11" align="center">
                                基本健康情况
                            </td>
                            <td colspan="3">
                                <div class="divtitle"> 心、肺、肾、肝等疾病：</div>  <div id="isBHXFSGDisease" style="float: left;" col="IsBHXFSGDisease"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 恶性肿瘤、血管瘤病史：</div>  <div id="isBHZLDisease" style="float: left;" col="IsBHZLDisease"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 体内是否有异物如金属架、硅胶等：</div>  <div id="isBHForeignBody" style="float: left;" col="IsBHForeignBody"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 严重器质性心脏病及各种手术恢复期：</div>  <div id="isBHOperationConvalescence" style="float: left;" col="IsBHOperationConvalescence"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 心脏血管疾病及病史者康复期等情况：</div>  <div id="isBHConvalescence" style="float: left;" col="IsBHConvalescence"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 脑梗、脑血栓疾病：</div>  <div id="isBHNaoDisease" style="float: left;" col="IsBHNaoDisease"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 脑梗、脑血栓疾病：</div>  <div id="isBHHypertension" style="float: left;" col="IsBHHypertension"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 急性传染病：</div>  <div id="isBHInfectiousDisease" style="float: left;" col="IsBHInfectiousDisease"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 各种出血疾病障碍性贫血：</div>  <div id="isBHBloodDisease" style="float: left;" col="IsBHBloodDisease"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 癫痫病史：</div>  <div id="isBHEpilepsy" style="float: left;" col="IsBHEpilepsy"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div class="divtitle"> 严重外伤：</div>  <div id="isBHtrauma" style="float: left;" col="IsBHtrauma"></div>
                            </td>
                        </tr>



                    </table>

                </td>
            </tr>
            <tr>
                <td colspan="3" style="border-top:0px;padding-left:10px">
                    <div style="float:left">
                        注：
                    </div><div style="float:left">
                        1.本档案所填写客户情况必须确保真实，否则出现一切不良后果均由客户本人承担；
                        <br />
                        2.本档案自建立之日起，务必保护好客户资料信息，绝不向第三方泄露和提供。
                    </div>
                </td>

            </tr>
            <tr>
                <td colspan="3" align="center">
                    <a id="btnAdd" class="btn btn-success" onclick="showSaveForm(true)"><i class="fa fa-plus"></i>方案设计</a>
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center">
                    <input type="hidden" id="treatmentId" />
                    <textarea id="treatmentContent" col="TreatmentContent" class="form-control" cols="40" rows="5"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center">
                    特殊说明
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center">
                    <textarea id="treatmentText" col="TreatmentText" class="form-control" cols="40" rows="5"></textarea>
                </td>

            </tr>
            <tr>
                <td style="padding-left:10px">
                    费用
                </td>
                <td colspan="2">
                    <input id="fee" col="Fee" type="text" />元
                </td>

            </tr>


        </table>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    var personid = ys.request("personid");

    $("#personId").val(personid);
    $(function () {

       //单选
        {
            $("#sleepTimeValue").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(EnumSleepTime).EnumToDictionaryString()))
            });
            $("#isStayUpLate").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#sleepHabitsValue").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(EnumSleepHabits).EnumToDictionaryString()))
            });
            $("#sleepQualityValue").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(EnumSleepQuality).EnumToDictionaryString()))
            });
            $("#eyeUseTimeValue").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(EnumEyeUseTimeValue).EnumToDictionaryString()))
            });
            $("#eyeUseTimeLongestValue").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(EnumEyeUseTimeLongest).EnumToDictionaryString()))
            });

            $("#isBHXFSGDisease").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#isBHZLDisease").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });

            $("#isBHOperationConvalescence").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#isBHConvalescence").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });

            $("#isBHNaoDisease").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#isBHHypertension").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#isBHInfectiousDisease").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#isBHEpilepsy").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });
            $("#isBHtrauma").ysRadioBox({
                data: ys.getJson(@Html.Raw(typeof(IsEnum).EnumToDictionaryString()))
            });

        }
        //多选
        $("#eyeUseTypes").ysCheckBox({
                data: ys.getJson(@Html.Raw(typeof(EnumEyeUseType).EnumToDictionaryString()))
        });

        $("#eyeUsePeriodS").ysCheckBox({
                data: ys.getJson(@Html.Raw(typeof(EnumEyeUsePerio).EnumToDictionaryString()))
            });

        getForm();

        $("#form").validate({
            rules: {
                personName: { required: true }
            }
        });
    });

    function getForm() {

        if (id > 0) {

            ys.ajax({
                url: '@Url.Content("~/prescription/GetFormJson")' + '?id=' + id,
                type: "get",
                success: function (obj) {
                    if (obj.Tag == 1) {
                        var result = obj.Data;
                        //console.log(result)
                        $("#personId").val(result.PersonIdStr);
                        $("#treatmentId").val(result.TreatmentIdStr);

                        if (result.IsMyopia==1) {
                            $("#isMyopia").prop("checked", true);
                        }

                        if (result.IsAstigmatism == 1) {
                            $("#isAstigmatism").prop("checked", true);
                        }
                        if (result.IsAmblyopia == 1) {
                            $("#isAmblyopia").prop("checked", true);
                        }
                        if (result.IsXerophthalmia == 1) {
                            $("#isXerophthalmia").prop("checked", true);
                        }
                        if (result.IsFeiWenZheng == 1) {
                            $("#isFeiWenZheng").prop("checked", true);
                        }
                        if (result.IsPresbyopia == 1) {
                            $("#isPresbyopia").prop("checked", true);
                        }
                        if (result.IsEyeAging == 1) {
                            $("#isEyeAging").prop("checked", true);
                        }
                        $("#form").setWebControls(result);

                    }
                }
            });
        }

        else {

            if (personid != null) {

                ys.ajax({
                    url: '@Url.Content("~/person/GetFormJson")' + '?id=' + personid,
                    type: "get",
                    success: function (obj) {
                        if (obj.Tag == 1) {
                            var result = obj.Data;
                            $("#form").setWebControls(result);
                        }
                    }
                });
            }
        }
    }

    function saveForm(index) {
        if ($("#form").validate().form()) {

            var postData = $("#form").getWebControls({ Id: id });

            postData.PersonId = $("#personId").val();
            postData.TreatmentId = $("#treatmentId").val();

            if ($("#isMyopia").is(':checked')) {
                postData.IsMyopia =1;
            }
            if ($("#isAstigmatism").is(':checked')) {
                postData.IsAstigmatism = 1;
            }
            if ($("#isAmblyopia").is(':checked')) {
                postData.IsAmblyopia = 1;
            }
            if ($("#isXerophthalmia").is(':checked')) {
                postData.IsXerophthalmia = 1;
            }
            if ($("#isFeiWenZheng").is(':checked')) {
                postData.IsFeiWenZheng = 1;
            }
            if ($("#isPresbyopia").is(':checked')) {
                postData.IsPresbyopia = 1;
            }
            if ($("#isEyeAging").is(':checked')) {
                postData.IsEyeAging = 1;
            }


            ys.ajax({
                url: '@Url.Content("~/prescription/SaveFormJson")',
                type: "post",
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }

    function callbackfun(v, t) {

        $("#treatmentId").val(v);
        $("#treatmentContent").val(t);
        //alert(v);
        //alert(t);

    }

      function showSaveForm() {
        var id = 0;

        ys.openDialog({
            title: id > 0 ? "调整方案" : "添加方案",
            content: '@Url.Content("~/treatment/treatmentList")',

        });




    }
</script>
